package com.shenghua.shiro;

import com.shenghua.dao.bean.UserBean;
import com.shenghua.dao.model.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

/**
 * @author: yzr
 * @date: 2020/2/24
 */
public class ShiroUtil {
    public static User getUser() {
        UserBean userBean = (UserBean) SecurityUtils.getSubject().getPrincipals().getPrimaryPrincipal();
        User user = null;
        if(userBean != null) {
            user = userBean.getUser();
        }
        return user;
    }

    public static Subject getSubject() {
        return SecurityUtils.getSubject();
    }
}
